package com.wonder.app.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vtuzx.core.bean.dto.VtuzxToken;
import com.wonder.app.domain.SaleOrder;
import com.wonder.app.domain.SyncOrder;
import com.wonder.app.request.SaleOrderRequest;
import com.wonder.app.request.SyncOrderRequest;
import com.wonder.app.service.SyncOrderService;
import com.wonder.common.common.AjaxMap;
import com.wonder.common.common.CommonPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * <p>说明： 订单履历controller</P>
 * @version: 1.1.0
 * @author: Wonder
 * @time    2023-4-19
 *
 */
@Api(tags = "订单同步外层")
@RestController
@RequestMapping("/app/syncOrder")
public class SyncOrderController {
    @Autowired
    private SyncOrderService syncOrderService;

    @ApiOperation(value = "订单同步履历列表")
    @RequestMapping(value = "/index", method = RequestMethod.POST)
    public Map<String,Object> index(@RequestBody SyncOrderRequest syncOrderRequest) {
        Page<SyncOrder> page = new Page<SyncOrder>(syncOrderRequest.getPage(), syncOrderRequest.getLimit());
        IPage<SyncOrder> list = syncOrderService.selectList(syncOrderRequest, page);

        Map<String,Object> retMap=new HashMap<>();
        retMap.put("data", CommonPage.restPage(list));


        return AjaxMap.success(retMap);
    }

    /**
     * @explain 导出追溯码
     * @param
     * @return  Map<String,Object>
     * @author  Wonder
     */
    @PostMapping("/dump_data")
    @ApiOperation(value = "导出数据", notes = "作者：Wonder")
    public Map<String,Object> dumpdata(@RequestBody Map<String,Object> map) {
        return syncOrderService.dumpdata(map);
    }
}
